package com.yloveg.impl;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yloveg.dao.ShopInfoMapper;
import com.yloveg.entity.ShopInfo;
import com.yloveg.entity.ShopInfoExtend;
import com.yloveg.service.ShopInfoService;

@Service
public class ShopInfoServiceImpl implements ShopInfoService {
 
    @Autowired
    private ShopInfoMapper shopInfoMapper;

	@Override
	public int insertShopInfo(ShopInfo info) {
		// TODO Auto-generated method stub
		info.setCreateDate(new Date());
		info.setState(1);
		info.setShopAtive("1");
		return shopInfoMapper.insert(info);
	}

	@Override
	public ShopInfo queryOneShopInfo(ShopInfo info) {
		// TODO Auto-generated method stub
		List<ShopInfo> listShop = shopInfoMapper.selectByTerm(info);
		if(listShop.size()>0){
			return listShop.get(0);
		}else{
			return null;
		}
	}

	@Override
	public int updateShopInfo(ShopInfo info) {
		// TODO Auto-generated method stub
		info.setUpdateDate(new Date());
		return shopInfoMapper.updateByPrimaryKeySelective(info);
	}

	@Override
	public PageInfo<ShopInfo> queryProductContentShopInfoPage(int page, int limit, ShopInfo info) {
		// TODO Auto-generated method stub
	    PageHelper.startPage(page, limit);
	    List<ShopInfo> listShop = shopInfoMapper.selectByTerm(info);
	    PageInfo<ShopInfo> resultPage = new PageInfo<ShopInfo>(listShop);
	    return resultPage;
	}

}
